package com.ruoyi.erp.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.erp.domain.LedyUserSimple;
import com.ruoyi.erp.service.ILedyUserSimpleService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 办案人员Controller
 * 
 * @author ztj
 * @date 2023-04-06
 */
@RestController
@RequestMapping("/erp/userSimple")
public class LedyUserSimpleController extends BaseController
{
    @Autowired
    private ILedyUserSimpleService ledyUserSimpleService;

    /**
     * 查询办案人员列表
     */
    @PreAuthorize("@ss.hasPermi('erp:userSimple:list')")
    @GetMapping("/list")
    public TableDataInfo list(LedyUserSimple ledyUserSimple)
    {
        startPage();
        List<LedyUserSimple> list = ledyUserSimpleService.selectLedyUserSimpleList(ledyUserSimple);
        return getDataTable(list);
    }

    /**
     * 导出办案人员列表
     */
    @PreAuthorize("@ss.hasPermi('erp:userSimple:export')")
    @Log(title = "办案人员", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, LedyUserSimple ledyUserSimple)
    {
        List<LedyUserSimple> list = ledyUserSimpleService.selectLedyUserSimpleList(ledyUserSimple);
        ExcelUtil<LedyUserSimple> util = new ExcelUtil<LedyUserSimple>(LedyUserSimple.class);
        util.exportExcel(response, list, "办案人员数据");
    }

    /**
     * 获取办案人员详细信息
     */
    @PreAuthorize("@ss.hasPermi('erp:userSimple:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(ledyUserSimpleService.selectLedyUserSimpleById(id));
    }

    /**
     * 新增办案人员
     */
    @PreAuthorize("@ss.hasPermi('erp:userSimple:add')")
    @Log(title = "办案人员", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LedyUserSimple ledyUserSimple)
    {
        return toAjax(ledyUserSimpleService.insertLedyUserSimple(ledyUserSimple));
    }

    /**
     * 修改办案人员
     */
    @PreAuthorize("@ss.hasPermi('erp:userSimple:edit')")
    @Log(title = "办案人员", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LedyUserSimple ledyUserSimple)
    {
        return toAjax(ledyUserSimpleService.updateLedyUserSimple(ledyUserSimple));
    }

    /**
     * 删除办案人员
     */
    @PreAuthorize("@ss.hasPermi('erp:userSimple:remove')")
    @Log(title = "办案人员", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(ledyUserSimpleService.deleteLedyUserSimpleByIds(ids));
    }
}
